package chapter19.file;

import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;

/**
 * @Auther: Tx
 * @Date: 2022/7/16 16:39
 */
public class FileCreat {
    public static void main(String[] args) {

    }

    @Test
//    创建文件方式1：
    void created01() throws IOException {
        String path = "e://new.txt";
        File file = new File(path);
        file.createNewFile();
    }

    @Test
//    创建文件方式2：
    void created() {
        File file = new File("e://");
        String name = "new2.txt";
        File Newfile = new File(file, name);
        try {
            Newfile.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
//    创建文件方式3：
    void created03() throws IOException {
        String parent = "e://";
        String child = "new3.txt";
        File file = new File(parent, child);
        file.createNewFile();

    }
}
